//
//  BaseCollectionView.m
//  GOGOTravel
//
//  Created by dllo on 16/3/7.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "BaseCollectionView.h"

@implementation BaseCollectionView


- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout{
    
    self = [super initWithFrame:frame collectionViewLayout:layout];
    if (self) {
        if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"yeJianMoShi"] isEqualToString:@"isDay"]) {
            self.backgroundColor = DAYCOLOR;
        }else{
            self.backgroundColor = NIGHTCOLOR;
        }
        
        
    }
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"yeJianMoShi" object:nil];
        
        
   return self;
}
- (void)changeColor:(NSNotification *)notification{
    
    if ([[[NSUserDefaults standardUserDefaults]objectForKey:@"yeJianMoShi"]isEqualToString:@"isNight"]) {
        self.backgroundColor = NIGHTCOLOR;
    }else{
        
        self.backgroundColor = DAYCOLOR;
    }
    
    
}


-(void)dealloc{
     [[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeColor" object:nil];
    [super dealloc];
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
